import 'package:flutter/material.dart';
import 'package:flutter_module/test_list_beans.dart';

final todos = List.generate(
    20,
        (i) =>
        Todo('Todo $i', 'A description of whta needs to be done for Tod $i'));

class TodoScreen extends StatelessWidget {
  final List<Todo> todos;

  const TodoScreen({super.key, required this.todos});

  @override
  Widget build(BuildContext context) {
    final String title = ModalRoute.of(context)?.settings.name ?? "Todo Screen";
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: ListView.builder(
          itemCount: todos.length,
          itemBuilder: (context, index) {
            return ListTile(
              title: Text(todos[index].title),
              onTap: () {
                Navigator.push(context, MaterialPageRoute(
                    builder: (context) => DetailScreen(todo: todos[index])));
              },
            );
          }),
    );
  }
}

class DetailScreen extends StatelessWidget {
  final Todo todo;

  const DetailScreen({super.key, required this.todo});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(todo.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Text(todo.description),
      ),
    );
  }
}